package com.qf.day01;

/**
 * @author lixu
 */
public class SynchronizedDemo {

    private byte[] o1 = new byte[11];// 一把锁
    private byte[] o2 = new byte[11];// 一把锁

    public static void main(String[] args) {

        SynchronizedDemo synchronizedDemo = new SynchronizedDemo();


        for (int i = 0; i < 100; i++) {
            new Thread(() -> {
                synchronizedDemo.a();
                synchronizedDemo.b();
            }).start();
        }


    }
    public void a(){
        synchronized (o1){
            System.out.println("我是a");
            b();
        }
    }
    public void b(){
        synchronized (o2){
            System.out.println("我是b");
            //a();
        }
    }

}
